package com.example.demo.dao;

import com.example.demo.model.Userinfo;
import com.example.demo.model.vo.UserinfoVO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
public interface UserMapper {

    @Insert("insert into userinfo(username,password,type,updatetime) values (#{username},#{password},#{type},#{updatetime})")
    int reg(Userinfo userinfo);

    @Select("select * from userinfo where username = #{username}")
    Userinfo getUserByName(@Param("username")String username);

    @Select("select * from userinfo where id = #{uid}")
    UserinfoVO getUserById(@Param("uid")Integer uid);

    @Update("update userinfo set password = #{password},updatetime = #{updatetime} where username = #{username}")
    int recover(Userinfo userinfo);

    @Update("update userinfo set username = #{username},password = #{password},email = #{email} where id = #{id}")
    int updateUser(Userinfo userinfo);

    @Update("update userinfo set photo = #{photo} where id = #{id}")
    int setUserPhoto(Userinfo userinfo);

    @Insert("insert into proveinfo(username,password,prove) values (#{username},#{password},#{prove})")
    int addWriter(Userinfo userinfo);

}
